<template>
  <div>
    <h1>用户-添加理财</h1>

    <table>
      <tr>
        <td>理财名称</td>
        <td>{{info.MName }}</td>
      </tr>
      <tr>
        <td>利息</td>
        <td>{{info.LxNumber }}</td>
      </tr>
      <tr>
        <td>最低金额</td>
        <td>{{info.YearMoney }}</td>
      </tr>
      <tr>
        <td>风险等级</td>
        <td>{{info.Lv }}</td>
      </tr>
      <tr>
        <td>理财金额</td>
        <td>
          <input type="text" v-model="moneylc" >
        </td>
      </tr>
      <tr>
        <td>预计收货金额</td>
        <td>{{ (info.LxNumber*moneylc).toFixed(2) }} CNY</td>
      </tr>
      <tr>
        <td></td>
        <td>
          <input type="button" value="理财" @click="add" >
        </td>
      </tr>

    </table>

  </div>
</template>

<script setup lang="ts">
       import axios from 'axios';
    import {reactive,toRefs,onMounted} from 'vue'
    import { useUserStors } from '@/stors/user';
    import {useRoute} from 'vue-router';
import router from '@/router';

    let rou=useRoute();

const useStors=useUserStors();

  let data:any=reactive({
    info:{},
    moneylc:''
  })

let {info,moneylc} =toRefs(data);

  onMounted(()=>{
    getList();
  })


  const getList=()=>{
      axios({
        url:'/api/UserMoney/GetQuery',
        method:'get',
        params:{id:rou.query.id}
      }).then(res=>{
        console.log(res.data[0]);
        
        info.value=res.data[0]

      }).catch(err=>{
      })
    }

    const add=()=>{
      if (moneylc.value<info.value.YearMoney) {
        return alert('理财金额不能低于最低金额');
      }

      alert('理财成功');
      router.push('/uuserMoney')
    }

</script>

<style scoped>

</style>